/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.deployment.helper;

import com.cea.papyrus.core.IPapyrusUIConstants;
import com.cea.papyrus.core.helper.GraphEdgeHelper;
import com.cea.papyrus.core.helper.IGraphElementHelper;
import com.cea.papyrus.diagram.classdiagram.helper.ClassDiagramModelerHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeAbstractionHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeDependencyHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeRealizationHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeUsageHelper;

/**
 * Defines management of deployment diagrams.
 * Extends ClassDiagramModelerHelper to import all its elements.
 */
public class DeploymentDiagramModelerHelper extends ClassDiagramModelerHelper {

	/**
	 * 
	 */
	private static DeploymentDiagramModelerHelper EINSTANCE;

	// set Uml element that can be created within a deployment diagram
	/**
	 * 
	 */
	protected final Class deploymentElementTypes[] = { 
			org.eclipse.uml2.uml.Node.class,
			org.eclipse.uml2.uml.Artifact.class,
			org.eclipse.uml2.uml.DeploymentSpecification.class,
			org.eclipse.uml2.uml.Device.class,
			org.eclipse.uml2.uml.ExecutionEnvironment.class,
			org.eclipse.uml2.uml.InstanceSpecification.class,
			org.eclipse.uml2.uml.Property.class	};

	// Set of factory that are in the same order that elment types
	/**
	 * 
	 */
	protected final IGraphElementHelper deploymentNodeFactory[] = { 
			new NodeNodeHelper(),
			new NodeArtifactHelper(), 
			new NodeDeploymentSpecificationHelper(),
			new NodeDeviceHelper(),
			new NodeExecutionEnvironmentHelper(),
			new NodeInstanceSpecificationHelper(), 
			new NodePropertyHelper() };

	/**
	 * The edge factory.
	 */
	protected GraphEdgeHelper deploymentEdgeFactory[] = { 
			new EdgeAssociationHelper(),
			new EdgeCommunicationPathHelper(),
			new EdgeManifestationHelper(), 
			new EdgeDeploymentHelper(),
			new EdgeDependencyHelper(),
			new EdgeAbstractionHelper(),
			new EdgeUsageHelper(),
			new EdgeRealizationHelper()};

	/**
	 * The edge types.
	 */
	protected Class<?> deploymentEdgeTypes[] = { 
			org.eclipse.uml2.uml.Association.class,
			org.eclipse.uml2.uml.CommunicationPath.class,
			org.eclipse.uml2.uml.Manifestation.class,
			org.eclipse.uml2.uml.Deployment.class,
			org.eclipse.uml2.uml.Dependency.class,
			org.eclipse.uml2.uml.Abstraction.class,
			org.eclipse.uml2.uml.Usage.class,
			org.eclipse.uml2.uml.Realization.class};

	/**
	 * Create the factories for model elements.
	 */
	public DeploymentDiagramModelerHelper() {
		super();
		// For nodes
		for (int i = 0; i < this.deploymentElementTypes.length; i++) {
			creationFactoryMap.put(deploymentElementTypes[i], deploymentNodeFactory[i]);
		}
		// For edges
		for (int i = 0; i < deploymentEdgeTypes.length; i++) {
			creationFactoryMap.put(deploymentEdgeTypes[i], deploymentEdgeFactory[i]);
		}
	}

	/**
	 * 
	 * 
	 * @return this instance of ModelResourceManager
	 */
	public static DeploymentDiagramModelerHelper getInstance() {
		if (EINSTANCE == null) {
			EINSTANCE = new DeploymentDiagramModelerHelper();
		}
		return EINSTANCE;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.cea.papyrus.common.factories.IModelerFactory#getId()
	 */
	/**
	 * 
	 * 
	 * @return 
	 */
	@Override
	public String getId() {
		return IPapyrusUIConstants.DEPLOYMENT_DIAGRAM;
	}
}
